class Solution {
public:
    int maxArea(vector<int>& height) {
        int begin = 0, end = height.size() - 1;
        int ret = 0;

        while (begin < end)
        {
            int v = min(height[begin], height[end]) * (end - begin);

            if (height[begin] < height[end])
                begin++;
            else
                end--;

            ret = max(ret, v);
        }
        return ret;
    }
};